from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response


class PageNumberPaginations(PageNumberPagination):
    page_size = 5  # 每页数据量
    page_query_param = 'page'  # ?page=1跳转页
    max_page_size = 10  # 每页最大数据量
    page_size_query_param = 'size'

    # 重写这个，是更改该函数的返回格式
    def get_paginated_response(self, data):
        return Response({
            'links': {
                'next': self.get_next_link(),
                'previous': self.get_previous_link()
            },
            'page_size':self.page_size,
            'count': self.page.paginator.count,
            'results': data})
class PageNumberMessagePaginations(PageNumberPagination):
    page_size = 4  # 每页数据量
    page_query_param = 'page'  # ?page=1跳转页
    max_page_size = 10  # 每页最大数据量
    page_size_query_param = 'size'

    # 重写这个，是更改该函数的返回格式
    def get_paginated_response(self, data):
        return Response({
            'links': {
                'next': self.get_next_link(),
                'previous': self.get_previous_link()
            },
            'page_size':self.page_size,
            'count': self.page.paginator.count,
            'results': data})
class PageNumberEvectionPaginations(PageNumberPagination):
    page_size = 5  # 每页数据量
    page_query_param = 'page'  # ?page=1跳转页
    max_page_size = 10  # 每页最大数据量
    page_size_query_param = 'size'

    # 重写这个，是更改该函数的返回格式
    def get_paginated_response(self, data):
        return Response({
            'links': {
                'next': self.get_next_link(),
                'previous': self.get_previous_link()
            },
            'page_size':self.page_size,
            'count': self.page.paginator.count,
            'results': data})
class SalaryPagenation(PageNumberPagination):
    page_size = 6  # 每页数据量
    page_query_param = 'page'  # ?page=1跳转页
    max_page_size = 12  # 每页最大数据量
    page_size_query_param = 'size'

    # 重写这个，是更改该函数的返回格式
    def get_paginated_response(self, data):
        return Response({
            'links': {
                'next': self.get_next_link(),
                'previous': self.get_previous_link()
            },
            'page_size':self.page_size,
            'count': self.page.paginator.count,
            'results': data})
